﻿using Angle.Krill.SystemConfig;
using Angle.Krill.Utils;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Angle.Krill
{
    public partial class General : Form
    {
        public General()
        {
            InitializeComponent();
        }

        private void General_Load(object sender, EventArgs e)
        {
            JObject jGeneral = SysConfigHelper.Instance.SysConfig?.General;

            this.chkStartup.Checked = jGeneral?.Value<bool?>("AutoStartup") ?? false;
        }

        private void chkStartup_CheckedChanged(object sender, bool value)
        {
            AutoStartupHelper.Instance.SetAutoStartup(value);

            JObject jGeneral = SysConfigHelper.Instance.SysConfig.General;

            jGeneral["AutoStartup"] = value;

            SysConfigHelper.Instance.SaveSysConfig();
        }
    }
}
